<?php
/**
 * Flea Site
 *
 * @copyright  Copyright (c) 2008 Movoin Studio (http://movoin.com)
 * @license    Apache License 2.0
 * @version    $Id: jinbaoyuan-config.php 130 2009-05-21 14:23:24Z movoin $
 */

/**
 * 缓存目录位置
 */
FLEA::setAppInf('internalCacheDir', ROOT_DIR . '/_temp/runtime');

/**
 * 模式配置文件
 */
$deploy = defined('DEPLOY_MODE') && DEPLOY_MODE;
if ( $deploy ) {
    $lifetime = 86400; //一天
} else {
    $lifetime = 0;
}

/**
 * 返回配置
 */
$cacheid = 'config.' . ($this->_app ? $this->_app . '.' : '') . ($deploy ? 'deploy' : 'development');
$_config = FLEA::getCache($cacheid, $lifetime, true, true);
if (is_array($_config)) { return $_config; }

if ( $deploy ) {
    $mode = require 'deploy.php';

} else {
    $mode = require 'devel.php';

}

/**
 * 数据库配置文件
 */
$database = array (
        'dbDSN' => array(
          'driver' => 'mysql',
          'host' => 'localhost',
          'login' => 'rjinbaoy',
          'password' => 'jinbaoyuanmysqlmima',
          'database' => 'rjinbaoy_site',
          'port' => 3306,
          'charset' => 'utf8'
        ),
        'dbTablePrefix' => 'mo_'
);

/**
 * 环境配置文件
 */
$environment = array (
    'urlLowerChar' => true,
    'internalCacheDir' => ROOT_DIR . '/_temp/runtime',
    'logFileDir' => ROOT_DIR . '/_temp/log',
    'webControlsExtendsDir' => array(
        ROOT_DIR . '/site/apps/share/Webcontrol',
        ROOT_DIR . '/site/modules',
        ),
    'controllerAccessor' => 'ctl',
    'actionAccessor' => 'act',
    'columnAccessor' => 'colkey',
    'urlAlwaysUseAccessor' => false,
    'urlLowerChar' => true,
    'logFilename' => $this->_app . '_access.log',
    'fckDir' => ROOT_DIR . '/site/editor/fckeditor',
    'templatesDir' => ROOT_DIR . '/site/apps/' . $this->_app . '/View',
    'tpldir' => '/site/apps/' . $this->_app . '/View',
);

if($this->_app=='admin') {
    $difference = array(
        'RBACSessionKey'    => 'HICMS.ADMIN.SESSIONKEY',
        'dispatcher' => 'FLEA_Dispatcher_Auth',
        'autoQueryDefaultACTFile' => true,
        'defaultControllerACTFile' => ROOT_DIR . '/site/config/AdminACT.php',
        'autoSessionStart'  => true,
        'defaultController' => 'Login',
        'dispatcherAuthFailedCallback' => 'adminCallback'
    );
} else {
    $difference = array(
        'autoSessionStart' => false,
        'urlMode' => URL_REWRITE
    );
}

$_uploadDir = array(
    'uploadDir' => 'uploads/',
    'uploadPath' => ROOT_DIR . '/uploads',
);

$_config = array_merge( $database, $environment, $mode, $_uploadDir, $difference);
FLEA::writeCache($cacheid, $_config, true);
unset($database, $environment, $mode, $cacheid, $_uploadDir, $difference);
return $_config;
